/**
 * config info
 *
 * @type {string}
 */
const CONTEXT_PATH = "/grape";
const UTC_URL_ARG = "?b=0&u=" + Math.random() + "&t=" + Math.random() + "&c=0";

const AuditResult = {
    AUDIT_REJECT: false,
    AUDIT_PASS: true
};

// 页面路径编码
const PagePathCode = {
    A0001: 'A0001', //申请记录-新增页-保存按钮

    B0001: 'B0001', //审核记录-列表操作-审核按钮

    C0001: 'C0001', //发布记录-列表操作-执行发布按钮
    C0002: 'C0002', //发布记录-列表操作-再次发布按钮

    D0001: 'D0001', //应用管理-新增页-保存按钮
    D0002: 'D0002', //应用管理-列表操作-编辑按钮

    E0001: 'E0001', //首页-最新配置-同步GIT配置按钮
    E0002: 'E0002', //首页-最新配置-同步业务属性名按钮
    E0003: 'E0003', //首页-最新配置-列表操作-编辑按钮
    E0004: 'E0004', //首页-最新配置-列表操作-删除按钮
    E0005: 'E0005', //首页-最新配置-批量发布
    E0006: 'E0006', //首页-最新配置-批量导出

    F0001: 'F0001', //我的-权限列表-新增按钮
    F0002: 'F0002', //我的-权限列表-列表操作-清除按钮

    G0001: 'G0001', //首页-快速操作-快速发布按钮
    G0002: 'G0002', //首页-快速操作-指定发布按钮
    G0003: 'G0003', //首页-快速操作-打开解密限制
    G0004: 'G0004', //首页-快速操作-关闭解密限制

    H0002: 'H0002', //任务管理-列表操作-编辑按钮
    H0003: 'H0003', //任务管理-同步状态
    H0004: 'H0004', //任务管理-调度任务

    J0002: 'J0002', //Redis管理-删除按钮

    Z01: 'Z01' //首页-退出按钮

};

const ApiConfig = {
    // cache
    SESSION_INDEX_AREA_ID: "index_area_id",
    SESSION_INDEX_AREA_ID_NAME: "index_area_id_name",
    SESSION_DASHBOARD_SELECT_APP: "dashboard_select_app",

    // common
    NO_PERMISSION_ZDO: "no_permission.zdo",
    DASHBOARD_ZDO: "dashboard.zdo",
    AUDIT_LIST_ZDO: "record/audit_list.zdo",
    RELEASE_LIST_ZDO: "record/release_list.zdo",

    // record
    APPLY_LIST: CONTEXT_PATH + "/prop/apply_list" + UTC_URL_ARG,
    APPLY_DETAIL: CONTEXT_PATH + "/prop/apply_detail" + UTC_URL_ARG,
    APPLY_STATUS_UPDATE: CONTEXT_PATH + "/prop/apply_status_update" + UTC_URL_ARG + append_ua_pc(PagePathCode.B0001),
    APPLY_SAVE: CONTEXT_PATH + "/prop/apply_save" + UTC_URL_ARG + append_ua_pc(PagePathCode.A0001),
    APPLY_PERMISSION: CONTEXT_PATH + "/prop/apply_permission" + UTC_URL_ARG,
    RELEASE_LIST: CONTEXT_PATH + "/prop/release_list" + UTC_URL_ARG,
    // remote config
    REMOTE_CFG_LIST: CONTEXT_PATH + "/prop/remote_config_list" + UTC_URL_ARG,
    REMOTE_CFG_SAVE: CONTEXT_PATH + "/prop/remote_config_save" + UTC_URL_ARG + append_ua_pc(PagePathCode.E0003),
    REMOTE_CFG_DEL: CONTEXT_PATH + "/prop/remote_config_del" + UTC_URL_ARG + append_ua_pc(PagePathCode.E0004),
    REMOTE_CFG_BULK_DOWNLOAD: CONTEXT_PATH + "/prop/remote_config/bulk_download" + UTC_URL_ARG + append_ua_pc(PagePathCode.E0006),
    REMOTE_CFG_FILE_GET: CONTEXT_PATH + "/prop/remote_config/file_get" + UTC_URL_ARG,
    REMOTE_CFG_KEY_GET: CONTEXT_PATH + "/prop/remote_config/key_by_file_get" + UTC_URL_ARG,
    REMOTE_CFG_INDEX_KEY_GET: CONTEXT_PATH + "/prop/remote_config/index_key_get" + UTC_URL_ARG,

    // task config
    TASK_CFG_LIST: CONTEXT_PATH + "/task/config_list" + UTC_URL_ARG,
    TASK_PROP_KEY_LIST: CONTEXT_PATH + "/task/prop_key_list" + UTC_URL_ARG,
    TASK_CFG_SAVE: CONTEXT_PATH + "/task/config_save" + UTC_URL_ARG + append_ua_pc(PagePathCode.H0002),
    TASK_SYNC_STATUS: CONTEXT_PATH + "/task/sync_status" + UTC_URL_ARG + append_ua_pc(PagePathCode.H0003),
    TASK_SCHEDULE_OPT: CONTEXT_PATH + "/task/schedule_opt" + UTC_URL_ARG + append_ua_pc(PagePathCode.H0004),

    // config
    APP_LIST: CONTEXT_PATH + "/config/app_list" + UTC_URL_ARG,
    APP_BY_AREAID: CONTEXT_PATH + "/config/app_by_areaid" + UTC_URL_ARG,
    APP_SAVE: CONTEXT_PATH + "/config/app_save" + UTC_URL_ARG,
    AREA_LIST: CONTEXT_PATH + "/config/area_list" + UTC_URL_ARG,
    BIZ_TYPE_LIST: CONTEXT_PATH + "/config/biz_type_list" + UTC_URL_ARG,
    HOST_NAME_LIST: CONTEXT_PATH + "/config/host_name_list" + UTC_URL_ARG,
    PRIVILEGE_SAVE: CONTEXT_PATH + "/config/privilege_save" + UTC_URL_ARG + append_ua_pc(PagePathCode.F0001),
    PRIVILEGE_LIST: CONTEXT_PATH + "/config/privilege_list" + UTC_URL_ARG,
    PRIVILEGE_CLEAR: CONTEXT_PATH + "/config/privilege_clear" + UTC_URL_ARG + append_ua_pc(PagePathCode.F0002),
    LOGIN_USER_AREALIST: CONTEXT_PATH + "/config/login_user_arealist" + UTC_URL_ARG,
    HOST_INFO_LIST: CONTEXT_PATH + "/config/host_info_list" + UTC_URL_ARG,
    HOST_INFO_SAVE: CONTEXT_PATH + "/config/host_info_save" + UTC_URL_ARG,

    // log
    USER_OPS_LIST: CONTEXT_PATH + "/log/user_opt_list" + UTC_URL_ARG,

    // git
    GIT_CONFIG_PUSH: CONTEXT_PATH + "/git/config_push" + UTC_URL_ARG,
    GIT_CONFIG_REVERT: CONTEXT_PATH + "/git/config_revert" + UTC_URL_ARG,
    GIT_REMOTE_CFG_SYNC: CONTEXT_PATH + "/git/remote_config/sync" + UTC_URL_ARG + append_ua_pc(PagePathCode.E0001),
    GIT_REMOTE_CFG_BULK_PUBLISH: CONTEXT_PATH + "/git/remote_config/bulk_publish" + UTC_URL_ARG + append_ua_pc(PagePathCode.E0005),

    // biz logout
    BIZ_LOGOUT: CONTEXT_PATH + "/biz_logout" + UTC_URL_ARG + append_ua_pc(PagePathCode.Z01),

    // config-biz 3rd
    BIZ3RD_CONFIG_PROP_STATUS: CONTEXT_PATH + "/config/biz_3rd/config_prop_status" + UTC_URL_ARG,
    BIZ3RD_CONFIG_FAST_PUB: CONTEXT_PATH + "/config/biz_3rd/config_fast_pub" + UTC_URL_ARG + append_ua_pc(PagePathCode.G0001),
    BIZ3RD_CONFIG_SPEC_PUB: CONTEXT_PATH + "/config/biz_3rd/config_spec_pub" + UTC_URL_ARG + append_ua_pc(PagePathCode.G0002),
    BIZ3RD_OPEN_DEC_ERR_LIMIT: CONTEXT_PATH + "/config/biz_3rd/open_decrypt_err_limit" + UTC_URL_ARG + append_ua_pc(PagePathCode.G0003),
    BIZ3RD_CLOSE_DEC_ERR_LIMIT: CONTEXT_PATH + "/config/biz_3rd/close_decrypt_err_limit" + UTC_URL_ARG + append_ua_pc(PagePathCode.G0004),

    // RAPI-dubbo+redis
    RAPI_DUBBO_LOAD_PAGE: CONTEXT_PATH + "/rapi/dubbo/load_page" + UTC_URL_ARG,
    RAPI_REIDS_GET_BIZ: CONTEXT_PATH + "/rapi/reids/get_biz_by_key" + UTC_URL_ARG,
    RAPI_REIDS_DEL_BIZ: CONTEXT_PATH + "/rapi/reids/del_biz_by_key" + UTC_URL_ARG + append_ua_pc(PagePathCode.J0002),
    RAPI_REIDS_DEL_ZCACHE: CONTEXT_PATH + "/rapi/reids/del_zcache_by_key" + UTC_URL_ARG + append_ua_pc(PagePathCode.J0002),


};

// * 申请状态:
//  * -1-已废弃 0-草稿 1-待审核 2-退回申请
//  * 3-待确认发布 4-待发布 5-补填配置 6-已发布待签字
//  * 7-待上线 8-待回滚 9-已上线 10-已回滚 98-回滚中 99-发布中
const ApplyStatus = {
    ABANONED: -1,
    DRAFT: 0,
    PRE_AUDIT: 1,
    RETURN_APPLY: 2,
    CONFIRM_RELEASE: 3,
    PRE_RELEASE: 4,
    FILL_CONFIG: 5,
    PRE_SIGN: 6,
    PRE_ONLINE: 7,
    PRE_REVERT: 8,
    ONLINE: 9,
    REVERT: 10,
    REVERT_ING: 98,
    RELEASE_ING: 99
};

const ApplyStatusLab = {
    ABANONED: "已废弃",
    DRAFT: "草稿",
    PRE_AUDIT: "待审核",
    RETURN_APPLY: "退回申请",
    CONFIRM_RELEASE: "待确认发布",
    PRE_RELEASE: "待发布",
    FILL_CONFIG: "补填配置",
    PRE_SIGN: "已发布待签字",
    PRE_ONLINE: "待上线",
    PRE_REVERT: "待回滚",
    ONLINE: "已上线",
    REVERT: "已回滚",
    REVERT_ING: "回滚中",
    RELEASE_ING: "发布中"
};

const UserOptTypeLab = {
    LOGIN: "登录",
    ADD: "增加",
    AUDIT_OK: "审批通过",
    AUDIT_FAIL: "审核不通过",
    RELEASE_SUCCESS: "发布成功",
    RELEASE_FAIL: "发布失败",
    DELETE: "删除",
    ABANDONED: "废弃",
    REVERT_FAIL: "回滚失败",
    REVERT_SUCCESS: "回滚成功",
    MODIFY: "修改",
    FILL_CONFIG: "补填配置",
    SIGN: "签字",
    SYNC_REMOTE_GIT_CFG: "同步远程GIT配置",
    DEL_REMOTE_GIT_CFG: "删除远程GIT配置项",
    SYNC_REMOTE_BIZ_KEY: "同步远程业务属性名",
    RELEASE_ING: "发布中",
    REVERT_ING: "回滚中",
    LOGOUT: "退出",
    FAST_PUB_CFG: "快速发布配置",
    SPEC_PUB_CFG: "指定发布配置",
    OPEN_DEC_ERR_LIMIT: "打开解密限制",
    CLOSE_DEC_ERR_LIMIT: "关闭解密限制",
    BULK_PUBLISH_CFG: "批量发布",
    BULK_DOWNLOAD_CFG: "批量导出",
    SCHEDULE_TASK: "调度任务",
};

// 操作类型:
//  * 1-登录 2-增加 3-审批通过 4-审核不通过 5-发布成功
//  * 6-发布失败 7-删除 8-废弃 9-回滚失败 10-回滚成功
//  * 11-修改 12-补填配置 13-签字 14-同步远程配置 15-删除远程配置项
//  * 16-同步远程业务属性名 17-发布中 18-回滚中 19-退出
//  * 20-快速发布配置 21-指定发布配置 22-打开解密限制 23-关闭解密限制
//  * 24-批量发布配置 25-批量导出配置 26-调度任务
const UserOptType = {
    LOGIN: 1,
    ADD: 2,
    AUDIT_OK: 3,
    AUDIT_FAIL: 4,
    RELEASE_SUCCESS: 5,
    RELEASE_FAIL: 6,
    DELETE: 7,
    ABANDONED: 8,
    REVERT_FAIL: 9,
    REVERT_SUCCESS: 10,
    MODIFY: 11,
    FILL_CONFIG: 12,
    SIGN: 13,
    SYNC_REMOTE_GIT_CFG: 14,
    DEL_REMOTE_GIT_CFG: 15,
    SYNC_REMOTE_BIZ_KEY: 16,
    RELEASE_ING: 17,
    REVERT_ING: 18,
    LOGOUT: 19,
    FAST_PUB_CFG: 20,
    SPEC_PUB_CFG: 21,
    OPEN_DEC_ERR_LIMIT: 22,
    CLOSE_DEC_ERR_LIMIT: 23,
    BULK_PUBLISH_CFG: 24,
    BULK_DOWNLOAD_CFG: 25,
    SCHEDULE_TASK: 26,
};

// 任务状态: 0-已打开 1-已关闭
const TaskStatus = {
    OPENED: 0,
    CLOSED: 1
};
const TaskStatusLab = {
    OPENED: "已打开",
    CLOSED: "已关闭"
};

// 业务属性名状态:
// 0-新增未用 1-线上已用 2-线下已用
const BizKeyStatus = {
    ADD_NU: 0,
    ONLINE_UD: 1,
    OFFLINE_UD: 2
};
const BizKeyStatusLab = {
    ADD_NU: "新增未用",
    ONLINE_UD: "线上已用",
    OFFLINE_UD: "线下已用",
};

function append_ua_pc(path_code) {
    return ("&ua_pc=" + path_code);
}

function new_append_ua_pc(path_code) {
    return ("?ua_pc=" + path_code);
}

